package com.zelin.manager.service.impl;

import com.zelin.common.utils.PageUtils;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zelin.common.utils.Query;

import com.zelin.manager.dao.BrandDao;
import com.zelin.manager.entity.BrandEntity;
import com.zelin.manager.service.BrandService;


@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {

   
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //构造查询包装器
        QueryWrapper<BrandEntity> wrapper =  new QueryWrapper<BrandEntity>();
        //得到参数key
        String key = (String) params.get("key");
        if (StringUtils.isNotBlank(key)){
            wrapper.like("name",key)
                    .or()
                    .like("first_char",key)
                    .or()
                    .like("id",key);
        }
        //开始分页查询
        IPage<BrandEntity> page = this.page(
                new Query<BrandEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}